package com.fenghuajueli.module_user.net;


import com.fenghuajueli.lib_data.entity.UserInfoEntity;
import com.fenghuajueli.lib_data.entity.goods.GoodsData;
import com.fenghuajueli.lib_data.entity.goods.SignStatusEntity;
import com.fenghuajueli.lib_data.entity.goods.WeChatPayInfoEntity;
import com.fenghuajueli.lib_data.entity.goods.ZfbPayInfoEntity;
import com.fenghuajueli.lib_data.entity.goods.ZfbSubscribeVipEntity;
import com.fenghuajueli.lib_net.observer.AndroidObservable;
import com.google.gson.JsonObject;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.HeaderMap;
import retrofit2.http.Headers;
import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.Path;
import retrofit2.http.Query;

public interface ApiService {


    @Headers("Content-Type: application/json")
    @POST("users/signUp")
    AndroidObservable<UserInfoEntity> register(@Body RequestBody requestBody);


    @Headers("Content-Type: application/json")
    @POST("users/signIn")
    AndroidObservable<UserInfoEntity> login(@Body RequestBody requestBody);


    @Headers("Content-Type: application/json")
    @PATCH("users/resetPassword")
    AndroidObservable<UserInfoEntity> resetPassword(@Body RequestBody requestBody);

    @Headers("Content-Type: application/json")
    @POST("sendCode")
    AndroidObservable<String> getVerificationCode(@Body RequestBody requestBody);

    @Headers({"Content-Type: application/json"})
    @GET("goods")
    AndroidObservable<GoodsData> getGoodsList(@HeaderMap Map<String, String> header, @Query("channel") String channel,
                                              @Query("is_sub") int is_sub, @Query("page") int page, @Query("page_size") int page_size
            , @Query("status") int status);

    @Headers({"Content-Type: application/json"})
    @POST("pay/preOrder")
    AndroidObservable<WeChatPayInfoEntity> getWechatOrder(@HeaderMap Map<String, String> header, @Body RequestBody requestBody);

    @Headers({"Content-Type: application/json"})
    @POST("pay/preOrder")
    AndroidObservable<ZfbPayInfoEntity> getZfbOrder(@HeaderMap Map<String, String> header, @Body RequestBody requestBody);

    @Headers({"Content-Type: application/json"})
    @GET("users/getUserInfo")
    AndroidObservable<UserInfoEntity.UserInfoBean> getUserInfo(@HeaderMap Map<String, String> header);

    @Headers({"Content-Type: application/json"})
    @PATCH("users/activePhone")
    AndroidObservable<UserInfoEntity.UserInfoBean> activePhone(@HeaderMap Map<String, String> header, @Body RequestBody requestBody);

    @Headers({"Content-Type: application/json"})
    @DELETE("users/{userid}")
    AndroidObservable<String> deleteRegisterUser(@Path("userid") int userId, @Header("token") String token,
                                                 @Query("phone") String phone,
                                                 @Query("password") String password,
                                                 @Query("code") String code,
                                                 @Query("is_encrypt") String is_encrypt,
                                                 @Query("app_id") String app_id);

    @Headers("Content-Type: application/json")
    @POST("users/signIn")
    AndroidObservable<UserInfoEntity> thirdLogin(@Body RequestBody requestBody);


    /**
     * 检测用户是否注册的接口
     *
     * @param requestBody
     * @return
     */
    @Headers("Content-Type: application/json")
    @POST("users/accountExists")
    AndroidObservable<Boolean> checkAccount(@Body RequestBody requestBody);

    /**
     * 支付宝订阅下单
     * @param token
     * @param requestBody
     * @return
     */
    @Headers("Content-Type: application/json")
    @POST("pay/preSubscribe")
    AndroidObservable<ZfbSubscribeVipEntity> preSubscribeOrder(@Header("token") String token, @Body RequestBody requestBody);

    /**
     * 检测用户是否处于订阅状态
     * @param token
     * @param channel
     * @return
     */
    @Headers("Content-Type: application/json")
    @GET("pay/isSubscribe")
    AndroidObservable<SignStatusEntity> checkSubscribeSignStatus(@Header("token") String token, @Query("channel") String channel);


    /**
     * 解绑第三方账户
     * @param token
     * @return
     */
    @Headers("Content-Type: application/json")
    @DELETE("users/delThirdAccount")
    AndroidObservable<String> unbindThirdAccount(@Header("token") String token);

    /**
     * 注销第三方账户
     * @param token
     * @return
     */
    @Headers("Content-Type: application/json")
    @DELETE("users/thirdSignOut")
    AndroidObservable<String> logoutThirdAccount(@Header("token") String token,
                                                 @Query("third_type") String third_type,
                                                 @Query("account") String account,
                                                 @Query("third_token") String third_token);


    /**
     * 第三方登录绑定账号处理
     * @param header
     * @param requestBody
     * @return
     */
    @Headers({"Content-Type: application/json"})
    @PATCH("users/bindPhone")
    AndroidObservable<UserInfoEntity.UserInfoBean.VipInfoBean> thirdBindPhone(@HeaderMap Map<String, String> header, @Body RequestBody requestBody);
}
